import sys
max = lambda a, b : b  if b > a else a
input = lambda: sys.stdin.readline().rstrip()
n, q = map(int, input().split(' '))
values = list(map(int, input().split(' ')))
colors = list(map(int, input().split(' ')))
ans = []
inf = 10e9
for _ in range(q):
    dp = [-inf] * (n + 1)
    a, b = map(int, input().split(' '))
    max1 = -inf
    max_color = -1
    max2 = -inf
    for i in range(n):
        color = colors[i]
        # 不同颜色
        mx = max1 if color != max_color else max2
        if mx < 0:
            mx = 0
        # 相同颜色选或者不选 取最大的
        temp = max(0, values[i] * a)

        dp[color] = max(dp[color] + temp, mx + values[i] * b)
        if dp[color] > max1:
            if color != max_color:
                max2 = max1
                max_color = color
            max1 = dp[color]
        elif dp[color] > max2 and color != max_color:
            max2 = dp[color]
    if max1 < 0:
        max1 = 0
    ans.append(max1)

print(*ans, sep='\n')










